<template>
  <van-actionsheet v-model="show"
                   overlay
                   title="分享">
    <div class="fengniao-share">
      <van-row gutter="20">
        <van-col span="6"
                 v-for="(item,index) in menuList"
                 :key="index">
          <div class="icon"
               :style="{backgroundColor:item.backgroundColor}"
               @click="goLink(item)">
            <van-icon :name="item.icon"
                      :style="{marginTop:`${item.marginTop}px`,fontSize:`${item.fontSize}px`}" />
          </div>
          <p v-text="item.title"
             class="title"></p>
        </van-col>
      </van-row>
    </div>
  </van-actionsheet>
</template>

<script>
import { wechatSDK } from '@/cordova/';
import baseCommon from '@/mixins/common.js';

export default {
  name: 'share',
  mixins: [baseCommon()],
  data() {
    return {
      show: false,
      menuList: [
        {
          title: '短信',
          icon: 'chat',
          event: 'message',
          backgroundColor: '#409EFF',
        },
        {
          title: '微信',
          icon: 'weixin',
          event: 'wechat',
          backgroundColor: '#54c15e',
          fontSize: 30,
          marginTop: -6,
        },
        {
          title: '朋友圈',
          icon: 'weixin',
          event: 'wechat',
          query: {
            type: 1,
          },
          backgroundColor: '#54c15e',
          fontSize: 30,
          marginTop: -6,
        },
        // {
        //   title: 'QQ',
        //   icon: 'qq',
        //   event: '',
        //   backgroundColor: '#709ceb',
        //   fontSize: 24,
        //   marginTop: -6,
        // },
      ],
    };
  },
  props: {
    value: {
      type: Boolean,
    },
  },
  watch: {
    show(n, o) {
      this.$emit('input', this.show);
    },
    value(n, o) {
      this.show = n;
    },
  },
  created() { },
  mounted() { },
  methods: {
    message(query) {
      this.$emit('message', query);
    },
    wechat(query) {
      this.$emit('wechat', query);
    },
    wechatShare(params) {
      const { title, href, description } = params;
      wechatSDK().then((res) => {
        this.$toast('正在调用微信...');
        return res.share({
          title,
          url: href,
          description,
        });
      });
    },
  },
};
</script>

<style>
</style>
